package team.archai.nexus.flow.listener;

import cn.hutool.extra.spring.SpringUtil;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import team.archai.nexus.flow.service.IProcessManage;

/**
 * 默认流程执行监听
 *
 * @author li shi bin
 */
public class DefaultExecListener implements ExecutionListener {
    @Override
    public void notify(DelegateExecution execution) {
        String eventName = execution.getEventName();
        IProcessManage processManage = SpringUtil.getBean(IProcessManage.class);
        switch (eventName) {
            case EVENTNAME_START:
                processManage.onStart(execution);
                break;
            case EVENTNAME_END:
                processManage.onEnd(execution);
                break;
            case EVENTNAME_TAKE:
                processManage.onTake(execution);
                break;
            default:
                break;
        }
    }
}
